<%@ page language="java" import="data.*,logic.*,java.util.*" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>SOS PLANET - Ayuda al mundo</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div id="wrapper">
<div class="content">
<div id="header">
	<%@ include file = "includes/header.jsp" %>
</div><!-- header -->

<div id="menu">      
	<%@ include file = "includes/menu.html" %>
</div><!-- menu -->

<div class="destino">
<h1>DESTINOS</h1>
</div>

<div class="elecciondestinos">
  <form class="cercanos" action="FrontController?res=destinos.jsp" method="post">
  <input type="hidden" name="iddest" value="-1" />
  <input type="submit" value="Destinos M&aacute;s Cercanos" />
  </form>
  <form class="populares" action="FrontController?res=destinos.jsp" method="post">
  <input type="hidden" name="iddest" value="-2" />
  <input type="submit" value="Destinos M&aacute;s Populares" />
  </form>
  <form class="todos" action="FrontController?res=destinos.jsp" method="post">
  <input type="hidden" name="iddest" value="-3" />
  <input type="submit" value="Todos los destinos" />
  </form>
</div>

<div class="clear"></div>

<div class="buscador">
  <%@ include file = "includes/FinderDestiny.jsp" %>
  </div>

<div class = "destinosbuscados">
	<%
	String s = request.getParameter("iddest");
	User u = (User)session.getAttribute("session.userAux");
	DestinationList l = DestinationList.getInstance();
	VolunteerProcessor vp = new VolunteerProcessor();
	List<Destination> dest = null;
	if(session.getAttribute("user") != null){
		//hay un usuario
		/*dest = vp.selectFavouriteDestinies();*/
	}else{
		System.out.print(s+"\n");
		if(s != null && s.equals("-1")){
			dest = vp.getNearestDestinies(u);
		}else if(s != null && s.equals("-2")){
			dest = l.getMostPopularDestinies();
		}else{
			dest = l.getDestinations();
		}
	}
	
	ActivityStore as = ActivityStore.getInstance();
	
	for(Destination e: dest){
	%>
	<div class="destinies">
		<form action="FrontController?res=actividades.jsp" method= "post">
		<input type="hidden" name="iddest" value="<%= e.getId() %>" />
		<input type="submit" value="<%= e.getName()%>"/>
		</form>
		<%
		List<Activity> la = as.selectRecentActivities(e.getId());
		for(Activity ac: la){
			%>
			<form class="cuadritos" action="FrontController?res=Actividad.jsp" method="post">
			<input type="hidden" name="idact" value="<%= ac.getId() %>" />
			<input type="submit" value="<%= ac.getName() %>" />
			</form>
			<%
		}
		%>
	</div>
	<%
	}
%>

</div>

    
<div id="footer">
	<%@ include file = "includes/footer.html" %>
</div><!--footer-->

</div><!--content-->
</div><!--wrapper-->
</body>
</html>